<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>2016秋冬审样会评审投票系统</title>

<meta name="description" content="User login page" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<!-- basic styles -->

<link
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/bootstrap.min.css"
	rel="stylesheet" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/font-awesome.min.css" />

<!--[if IE 7]>
		  <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

<!-- page specific plugin styles -->

<!-- fonts -->

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace-fonts.css" />

<!-- ace styles -->

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace-rtl.min.css" />

<!--[if lte IE 8]>
		  <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace-ie.min.css" />
		<![endif]-->

<!-- inline styles related to this page -->

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

<!--[if lt IE 9]>
		<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/html5shiv.js"></script>
		<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/respond.min.js"></script>
		<![endif]-->
<style type="text/css">


.table td {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	vertical-align: middle;
	text-align: center;
	
}
</style>
</head>

<body>
<div class="container-fluid">
  <div class="row">
  	<div class="col-xs-12">
	    <table class="table table-striped table-bordered ">
	    	<tr>
	    		<td colspan="7"><h3>2016秋冬审样会评审投票</h3>${sessionScope.userSession.sysUser.nickName }[${sessionScope.userSession.sysUser.company }]</td>
	    	</tr>
	    	<tr>
	    		<td >主题</td>
	    		<td colspan="2" id="jsubject">&nbsp;</td>
	    		<td colspan="4" rowspan="2" style="text-align: left;">
	    			评审投票说明：<br/>
	    			1、选择商品短码进行投票;<br/>
					2、修改时选择商品短码进行修改;<br/>
					3、所有产品属性为必选项;<br/>
					4、每件商品都要进行选择或者放弃;<br/>
	    		</td>
	    	</tr>
	    	<tr>
	    		<td >品类</td>
	    		<td colspan="2" id="jclass">&nbsp;</td>
	    	</tr>
	    	<tr>
	    		<td >短码</td>
	    		<td colspan="6">
	    			<div class="input-group">
	    				<input type="hidden" id="jcodeId" />
						<input type="text" id="short_code" class="form-control search-query" placeholder="请输入短码" />
						<span class="input-group-btn">
							<button type="button" class="btn btn-purple btn-sm" id="btn_search">
								查找
								<i class="icon-search icon-on-right bigger-110"></i>
							</button>
						</span>
					</div>
				</td>
	    	</tr>
	    	<tr>
	    		<td rowspan="6" sytle="vertical-align: middle;">产品属性</td>
	    		<td >类别</td>
	    		<td colspan="5">满意度分值</td>
	    	</tr>
	    	<tr>
	    		<td >版型</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_bx" type="radio" class="ace" value="1"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-info btn-lg">&nbsp;1&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_bx" type="radio" class="ace" value="2"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-purple btn-lg">&nbsp;2&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_bx" type="radio" class="ace" value="3"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-pink btn-lg">&nbsp;3&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_bx" type="radio" class="ace" value="4"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-warning btn-lg">&nbsp;4&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_bx" type="radio" class="ace" value="5"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-danger btn-lg">&nbsp;5&nbsp;</span></span>
						</label>
					</div>
				</td>
	    	</tr>
	    	<tr>
	    		<td >价格</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_jg" type="radio" class="ace" value="1"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-info btn-lg">&nbsp;1&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_jg" type="radio" class="ace" value="2"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-purple btn-lg">&nbsp;2&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_jg" type="radio" class="ace" value="3"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-pink btn-lg">&nbsp;3&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_jg" type="radio" class="ace" value="4"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-warning btn-lg">&nbsp;4&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_jg" type="radio" class="ace" value="5"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-danger btn-lg">&nbsp;5&nbsp;</span></span>
						</label>
					</div>
				</td>
	    	</tr>
	    	<tr>
	    		<td >款式</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ks" type="radio" class="ace" value="1"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-info btn-lg">&nbsp;1&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ks" type="radio" class="ace" value="2"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-purple btn-lg">&nbsp;2&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ks" type="radio" class="ace" value="3"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-pink btn-lg">&nbsp;3&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ks" type="radio" class="ace" value="4"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-warning btn-lg">&nbsp;4&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ks" type="radio" class="ace" value="5"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-danger btn-lg">&nbsp;5&nbsp;</span></span>
						</label>
					</div>
				</td>
	    	</tr>
	    	<tr>
	    		<td >颜色</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ys" type="radio" class="ace" value="1"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-info btn-lg">&nbsp;1&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ys" type="radio" class="ace" value="2"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-purple btn-lg">&nbsp;2&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ys" type="radio" class="ace" value="3"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-pink btn-lg">&nbsp;3&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ys" type="radio" class="ace" value="4"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-warning btn-lg">&nbsp;4&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ys" type="radio" class="ace" value="5"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-danger btn-lg">&nbsp;5&nbsp;</span></span>
						</label>
					</div>
				</td>
	    	</tr>
	    	<tr>
	    		<td valign="middle">面料</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ml" type="radio" class="ace" value="1"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-info btn-lg">&nbsp;1&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ml" type="radio" class="ace" value="2"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-purple btn-lg">&nbsp;2&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ml" type="radio" class="ace" value="3"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-pink btn-lg">&nbsp;3&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label>
							<input name="radio_ml" type="radio" class="ace" value="4"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-warning btn-lg">&nbsp;4&nbsp;</span></span>
						</label>
					</div>
				</td>
	    		<td >							
					<div class="radio">
						<label style="width: 90%">
							<input name="radio_ml" type="radio" class="ace" value="5"/>
							<span class="lbl">&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-danger btn-lg">&nbsp;5&nbsp;</span></span>
						</label>
					</div>
				</td>
	    	</tr>
	    	<tr>
	    		<td >投票</td>
	    		<td colspan="6">
	    			<button type="button" id="btn_vote" class="btn btn-danger btn-app btn-sm">投票</button>&nbsp;&nbsp;&nbsp;&nbsp;
	    			<button type="button" id="btn_unvote" class="btn btn-success btn-app btn-sm">放弃</button>&nbsp;&nbsp;&nbsp;&nbsp;
	    		</td>
	    	</tr>
	    </table>
    </div>
  </div>
</div>

	<!-- basic scripts -->

	<!--[if !IE]> -->

	<script type="text/javascript">
		window.jQuery
				|| document
						.write("<script src='${pageContext.request.contextPath}/resources/bt_v3/assets/js/jquery-2.0.3.min.js'>"
								+ "<"+"/script>");
	</script>

	<!-- <![endif]-->

	<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='${pageContext.request.contextPath}/resources/bt_v3/assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

	<script type="text/javascript">
		if ("ontouchend" in document)
			document
					.write("<script src='${pageContext.request.contextPath}/resources/bt_v3/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"/script>");
	</script>


	<script type="text/javascript"> 
		var g_vote = 0;// 0未投票 1已投票
		var g_code = "";//当前查找的短码
		function fn_vote() {
			var radio_jg = $('input[name="radio_jg"]:checked ').val();
			var radio_ks = $('input[name="radio_ks"]:checked ').val();
			var radio_ys = $('input[name="radio_ys"]:checked ').val();
			var radio_ml = $('input[name="radio_ml"]:checked ').val();
			var radio_bx = $('input[name="radio_bx"]:checked ').val();
			var hidden_jcodeId = $("#jcodeId").val();
			if(typeof(radio_bx) == "undefined" || typeof(radio_jg) == "undefined" || typeof(radio_ks) == "undefined" ||
				typeof(radio_ys) == "undefined" || typeof(radio_ml) == "undefined" || hidden_jcodeId == "" || hidden_jcodeId == null){
				alert("必须先查询一个短码，然后给每一个产品属性选一个分值!");
				
			}else{
				
				if(g_code != $("#short_code").val()){
					alert("请先查找当前输入的短码，再选择分值!");
					return;
				}
				
				if(g_vote > 0){
					if(confirm("您已投票，是否要重新投票?")){
					
					}else{
						return;
					}
				}
				var data = new Object();
				data['docStatus'] = "10";
				data['jg'] = radio_jg;
				data['ks'] = radio_ks;
				data['ys'] = radio_ys;
				data['ml'] = radio_ml;
				data['bx'] = radio_bx;
				data['jcodeId'] = $("#jcodeId").val();
				$.ajax({
							url : "${pageContext.request.contextPath}/admin/joeoneVote/saveJoeoneVote.do",
							async : true,
							dataType : 'json',
							type : 'POST',
							data : data,
							success : function(data, textStatus) {
								if (data.result == "success") {
									$("#jcodeId").val("");
									$("#jsubject").text("");
									$("#jclass").text("");
									$("input[name='radio_jg']:checked").prop("checked",false);
									$("input[name='radio_ks']:checked").prop("checked",false);
									$("input[name='radio_ys']:checked").prop("checked",false);
									$("input[name='radio_ml']:checked").prop("checked",false);
									$("input[name='radio_bx']:checked").prop("checked",false);
									alert("该短码投票成功！");
								} else {
									
									alert(data.message);
								}
							},
							error : function(jqXHR, textStatus, errorThrown) {
								var sessionstatus=jqXHR.getResponseHeader("sessionstatus");
								if(sessionstatus == "timeout"){
									alert("[timeout]您登陆已经超时，请重新登陆!");
									var req_address = "${pageContext.request.contextPath}/joeone/ipad/index.jsp";
									window.location.href  = req_address;
								}else{
									alert("网络连接失败，请重试!");
								}
							}
		
						});
				}
				
				
			

		}
		function fn_unvote() {
			var radio_jg = 0;
			var radio_ks = 0;
			var radio_ys = 0;
			var radio_ml = 0;
			var radio_bx = 0;
			var hidden_jcodeId = $("#jcodeId").val();
			if( hidden_jcodeId == null){
				alert("必须先查询一个短码!");
				
			}else{
				
				if(g_code != $("#short_code").val()){
					alert("请先查找当前输入的短码，再选择分值!");
					return;
				}
				if(g_vote > 0){
					if(confirm("您已投票，是否要重新投票?")){
					
					}else{
						return;
					}
				}

				var data = new Object();
				data['docStatus'] = "00";
				data['jg'] = radio_jg;
				data['ks'] = radio_ks;
				data['ys'] = radio_ys;
				data['ml'] = radio_ml;
				data['bx'] = radio_bx;
				data['jcodeId'] = $("#jcodeId").val();
				$.ajax({
							url : "${pageContext.request.contextPath}/admin/joeoneVote/saveJoeoneVote.do",
							async : true,
							dataType : 'json',
							type : 'POST',
							data : data,
							success : function(data, textStatus) {
								if (data.result == "success") {
									$("#jcodeId").val("");
									$("#jsubject").text("");
									$("#jclass").text("");
									$("input[name='radio_jg']:checked").prop("checked",false);
									$("input[name='radio_ks']:checked").prop("checked",false);
									$("input[name='radio_ys']:checked").prop("checked",false);
									$("input[name='radio_ml']:checked").prop("checked",false);
									$("input[name='radio_bx']:checked").prop("checked",false);
									alert("您已放弃该短码投票！");
								} else {
									
									alert(data.message);
								}
							},
							error : function(jqXHR, textStatus, errorThrown) {
								var sessionstatus=jqXHR.getResponseHeader("sessionstatus");
								if(sessionstatus == "timeout"){
									alert("[timeout]您登陆已经超时，请重新登陆!");
									var req_address = "${pageContext.request.contextPath}/joeone/ipad/index.jsp";
									window.location.href  = req_address;
								}else{
									alert("网络连接失败，请重试!");
								}
							}
		
						});
				}
				

		}
		function fn_search() {
			//查找之前清空界面数据
			$("#jsubject").text("");
			$("#jclass").text("");
			$("#jcodeId").val("");
			$("input[name='radio_jg']:checked").prop("checked",false);
			$("input[name='radio_ks']:checked").prop("checked",false);
			$("input[name='radio_ys']:checked").prop("checked",false);
			$("input[name='radio_ml']:checked").prop("checked",false);
			$("input[name='radio_bx']:checked").prop("checked",false);
			
			var short_code = $.trim($('#short_code').val());
			g_code = short_code;
			var data = new Object();
			data['jcode'] = short_code;
			$.ajax({
						url : "${pageContext.request.contextPath}/admin/joeoneCode/viewX.do",
						async : true,
						dataType : 'json',
						type : 'GET',
						data : data,
						success : function(data, textStatus) {
							if (data.result == "success") {
								$("#jsubject").text(data.data.jsubject);
								$("#jclass").text(data.data.jclass);
								$("#jcodeId").val(data.data.docId);
								//判断是否已经投票
								if(data.joeoneVote != ""){
									g_vote = 1;
								}else{
									g_vote = 0;
								}
															
								//赋值radio
								if(typeof(data.joeoneVote.jg) != "undefined"){
									$("input:radio[name='radio_jg'][value="+data.joeoneVote.jg+"]").prop("checked","checked");
								}else{
									$("input[name='radio_jg']:checked").prop("checked",false);
								}
								if(typeof(data.joeoneVote.ks) != "undefined"){
									$("input:radio[name='radio_ks'][value="+data.joeoneVote.ks+"]").prop("checked","checked");
								}else{
									$("input[name='radio_ks']:checked").prop("checked",false);
								}
								if(typeof(data.joeoneVote.ys) != "undefined"){
									$("input:radio[name='radio_ys'][value="+data.joeoneVote.ys+"]").prop("checked","checked");
								}else{
									$("input[name='radio_ys']:checked").prop("checked",false);
								}
								if(typeof(data.joeoneVote.ml) != "undefined"){
									$("input:radio[name='radio_ml'][value="+data.joeoneVote.ml+"]").prop("checked","checked");
								}else{
									$("input[name='radio_ml']:checked").prop("checked",false);
								}
								if(typeof(data.joeoneVote.bx) != "undefined"){
									$("input:radio[name='radio_bx'][value="+data.joeoneVote.bx+"]").prop("checked","checked");
								}else{
									$("input[name='radio_bx']:checked").prop("checked",false);
								}
							} else {
								$("#jcodeId").val("");
								$("input[name='radio_jg']:checked").prop("checked",false);
								$("input[name='radio_ks']:checked").prop("checked",false);
								$("input[name='radio_ys']:checked").prop("checked",false);
								$("input[name='radio_ml']:checked").prop("checked",false);
								$("input[name='radio_bx']:checked").prop("checked",false);
								alert(data.message);
							}
						},
						error : function(jqXHR, textStatus, errorThrown) {
							var sessionstatus=jqXHR.getResponseHeader("sessionstatus");
							if(sessionstatus == "timeout"){
								alert("[timeout]您登陆已经超时，请重新登陆!");
								var req_address = "${pageContext.request.contextPath}/joeone/ipad/index.jsp";
								window.location.href  = req_address;
							}else{
								alert("网络连接失败，请重试!");
							}
							
						}
	
					});
		}
		$(document).ready(function() {
			$("#btn_vote").bind("click", fn_vote);
			$("#btn_unvote").bind("click", fn_unvote);
			$("#btn_search").bind("click", fn_search);

		});
	</script>

</body>
</html>